package com.mysdnu.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

import com.mysdnu.mysdnu_android.R;
import com.mysdnu.utils.DensityUtil;

public class UserInfoAdapter extends BaseAdapter {
	private Context context;
	private List<String> list;
	private LayoutInflater inflater;

	public UserInfoAdapter(Context context, List<String> list) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.list = list;
		inflater = (LayoutInflater) context
				.getSystemService(context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		TextView textView = null;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_listview_slidingmenu,
					parent, false);
			textView = (TextView) convertView
					.findViewById(R.id.textView_slidingmenu);
			convertView.setTag(textView);
		} else {
			textView = (TextView) convertView.getTag();
		}
		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
				DensityUtil.dip2px(context, 30));
		textView.setLayoutParams(params);
		textView.setText(list.get(position));
		return convertView;
	}
}
